package com.liming.common.pojo.vo.product;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.liming.common.pojo.vo.coupon.mini.MiniCouponVO;
import com.liming.common.serializer.CentToYuanSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * @author liming
 * @date 2025/3/20
 */
@Data
@Schema(description = "小程序 - 商品VO")
public class MiniProductVO {

    @Schema(description = "商品ID")
    private Long id;

    @Schema(description = "商品名称")
    private String name;

    @Schema(description = "商品型号")
    private String modelNumber;

    @Schema(description = "商品售价")
    @JsonSerialize(using = CentToYuanSerializer.class)
    private Integer price;

    @Schema(description = "商品原价")
    @JsonSerialize(using = CentToYuanSerializer.class)
    private Integer originalPrice;

    @Schema(description = "商品销售数量")
    private Integer salesCount;

    @Schema(description = "商品品牌")
    private String brandName;

    @Schema(description = "商品分类")
    private String categoryName;

    @Schema(description = "商品主图链接地址")
    private String mainImageUrl;

    @Schema(description = "商品详情图片链接地址列表")
    private String detailImagesUrl;

    @Schema(description = "商品视频链接地址")
    private String videoLink;

    @Schema(description = "商品参数信息")
    private String parameters;

    @Schema(description = "商品功能特点介绍内容")
    private String features;

    @Schema(description = "优惠券")
    private List<MiniCouponVO> coupons;

    public List<String> getDetailImagesUrl() {
        if (ObjectUtil.isNull(detailImagesUrl)) {
            return List.of();
        }
        return List.of(detailImagesUrl.split(","));
    }

    public List<String> getParameters() {
        if (ObjectUtil.isNull(parameters)) {
            return List.of();
        }
        return List.of(parameters.split(","));
    }
}
